package com.liming.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author liming
 * @date 2025/2/25
 */
@Getter
@AllArgsConstructor
public enum DateScopeEnum {

    LAST_YEAR("lastYear", "去年"),
    LAST_MONTH("lastMonth", "上月"),
    LAST_WEEK("lastWeek", "上周"),
    YESTERDAY("yesterday", "昨日"),
    TODAY("today", "今日"),
    THIS_WEEK("thisWeek", "本周"),
    THIS_MONTH("thisMonth", "本月"),
    THIS_YEAR("thisYear", "今年");

    private final String scope;
    private final String desc;

    /**
     * 根据scope获取枚举
     *
     * @param scope 时间范围
     * @return DateScopeEnum
     */
    public static DateScopeEnum getByScope(String scope) {
        for (DateScopeEnum dateScopeEnum : DateScopeEnum.values()) {
            if (dateScopeEnum.getScope().equals(scope)) {
                return dateScopeEnum;
            }
        }
        return null;
    }
}
